<template>
  <div>
    <!-- 导航栏 -->
    <van-nav-bar>
      <!-- 自定义左侧 -->
      <template #left>
        <div class="logo"></div>
      </template>
      <!-- 自定义右侧 -->
      <template #right>
        <van-button @click="$router.push('/search')" class="btn-search" round icon="search" type="info"
          >搜索</van-button
        >
      </template>
    </van-nav-bar>

    <!-- tab栏 -->
    <van-tabs>
      <van-tab
        v-for="item in channels"
        :key="item.id"
        :title="item.name"
      >
        <!-- 使用组件 -->
        <artList :channel_id="item.id"/>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
// 导入articleList组件
import artList from "./articleList";
export default {
  // 注册组件
  components: {
    artList,
  },
  data() {
    return {
      channels: [],
    };
  },

  async created() {
    let res = await this.$axios({
      url: "/v1_0/user/channels",
    });

    this.channels = res.data.data.channels;
  },
};
</script>

<style scoped>
.logo {
  width: 120px;
  height: 100%;
  background: url(../../assets/logo.png) no-repeat center / cover;
}

.btn-search {
  width: 90px;
  height: 30px;
  background-color: rgba(255, 255, 255, 0.3);
}

::v-deep .van-icon-search {
  color: #fff !important;
}
</style>